package com.siwei.mes.upload;

import com.siwei.mes.common.annotation.AnonymousAccess;
import com.siwei.mes.common.result.Json;
import com.siwei.mes.upload.erp.UploadErpService;
import com.siwei.mes.upload.erp.entity.ErpAddTaskPhbLog;
import com.siwei.mes.upload.erp.entity.ErpPhbInfo;
import com.siwei.mes.upload.erp.entity.ErpPhbYclInfo;
import com.siwei.mes.upload.erp.entity.ErpWbcheckinfo;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 测试上传接口
 *
 * @Description: 测试上传接口
 * @Version: 1.0
 * @author: mlchen
 * @date: 2024/8/22 17:07
 */
@Api(value = "测试上传接口")
@RestController
@RequestMapping("testUpload")
public class TestUploadController {
    @Resource
    private UploadErpService uploadErpService;

    @AnonymousAccess
    @GetMapping("uploadWbcheckInfo")
    public Json uploadWbcheckInfo() {
        ErpWbcheckinfo entity = new ErpWbcheckinfo();
        entity.setWLID(9975L);
        entity.setQuickTestID(13L);
        entity.setQuickTestNo("SYWT24090300002");
        entity.setQuickTestResult("合格");
        entity.setQuickTestRemark("合格");
        entity.setBatchTestID(13L);
        entity.setBatchTestNo("SYWT24090300002");
        entity.setBatchTestResult("合格");
        entity.setBatchTestRemark("合格");
        uploadErpService.uploadWbcheckInfo(entity, true);
        return Json.succ();
    }

    @AnonymousAccess
    @GetMapping("uploadPhbInfo")
    public Json uploadPhbInfo() {
        ErpPhbInfo entity = new ErpPhbInfo();
        entity.setPhbId("390");
        entity.setPhbNo("868");
        entity.setTpz("C30");
        entity.setSnpz("PII52.5");
        entity.setLq("28");
        entity.setCreater("靓仔1");
        entity.setJbsj("66");
        entity.setKzp("9");
        entity.setPhbState("正在使用");
        entity.setRemark("备注");
        entity.setUsage("用途");

        List<ErpPhbYclInfo> phbYclInfoList = new ArrayList<>();
        phbYclInfoList.add(new ErpPhbYclInfo().setName("0-5碎石").setPzgg("0-5").setCate("粗骨料").setYl("100").setCw("0"));
        phbYclInfoList.add(new ErpPhbYclInfo().setName("机制砂").setPzgg("机制砂").setCate("细骨料").setYl("100").setCw("0"));

        entity.setYcls(phbYclInfoList);

        uploadErpService.uploadPhbInfo(entity, true);

        return Json.succ();
    }

    @AnonymousAccess
    @GetMapping("uplopadAddTaskPhbLog")
    public Json uplopadAddTaskPhbLog() {
        ErpAddTaskPhbLog entity = new ErpAddTaskPhbLog();
        entity.setTaskIds("77176");
        entity.setPhbId(390);
        entity.setPhbNo("869");
        uploadErpService.uploadAddTaskPhbLog(entity, true);
        return Json.succ();
    }
}
